package com.practice.sequence;

public class FirstRepeat {
	public int find(int a[]) {
		int n = a.length - 1;
		for (int i = 0; i <= n; i++) {
			int t = a[i] > n ? a[i] - n : a[i];
			if (a[t] > n) return t;
			a[t] = a[t] + n;
		}
		return -1;
	}
}